// 引用vue ，安装路由功能
import Vue from "vue";
import VueRouter from "vue-router"

// 1，页面组件 定义 (路由) 组件
import Home from "../views/Home.vue"
import Mall from "../views/Mall.vue"
import User from "../views/User.vue"
import Main from "../views/Main.vue"


// 安装路由功能
Vue.use(VueRouter)


// 2. 定义路由
const routes = [
    {
        path: '/',
        component: Main,
        redirect: '/home',
        children: [
            { path: '/user', component: User },//用户管理页面
            { path: '/home', component: Home },//首页
            { path: '/mall', component: Mall },//商品管理
        ]
    },
]

// 3,创建 router 实例，然后传 `routes` 配置

const router = new VueRouter({
    routes
})

export default router